/*
 * $Id: JAboutDialog.java 24 2009-03-31 23:40:10Z aaron.day $
 */
package org.crazydays.gameplan.swing;


import java.awt.Dimension;
import java.awt.Frame;
import java.io.File;
import java.io.IOException;
import java.net.URL;

import javax.swing.JDialog;
import javax.swing.JEditorPane;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

/**
 * AboutDialog
 */
public class JAboutDialog
        extends JDialog
{
	/** serial version uid */
	public final static long serialVersionUID =
	        "$Id: JAboutDialog.java 24 2009-03-31 23:40:10Z aaron.day $"
	                .hashCode();

	/** log */
	protected Log LOG = LogFactory.getLog(getClass());

	/** editor pane */
	protected JEditorPane editorPane;

	/**
	 * JAboutDialog constructor.
	 * 
	 * @param frame Parent frame
	 */
	public JAboutDialog(Frame frame)
	{
		super(frame, "About GamePlan", true);

		initialize();
	}

	/**
	 * Initialize about dialog.
	 */
	protected void initialize()
	{
		initializeEditorPane();
		pack();
	}

	/**
	 * Initialize editor pane.
	 */
	protected void initializeEditorPane()
	{
		editorPane = new JEditorPane();

		editorPane.setPreferredSize(new Dimension(300, 400));

		// setup content
		editorPane.setEditable(false);
		editorPane.setContentType("text/html");
		try {
			// TODO: revist and cleanup
			URL url =
			        new URL("file://"
			                + new File(".").getAbsolutePath()
			                + File.separator + "doc"
			                + File.separator + "about.html");

			editorPane.setPage(url);
		} catch (IOException e) {
			LOG.warn(new File(".").getAbsolutePath());
			editorPane.setText("Unable to load about.html");
		}

		add(editorPane);
	}
}
